package com.java.system.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.java.system.entity.Camera;
import com.java.system.entity.Result;
import com.java.system.mapper.CameraMapper;
import com.java.system.service.ICameraService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author xiaoman
 * @since 2023-07-12
 */
@Service
public class CameraServiceImpl extends ServiceImpl<CameraMapper, Camera> implements ICameraService {
    @Autowired
    CameraMapper cameraMapper;

    @Override
    public List<Camera> select() {
        LambdaQueryWrapper<Camera> queryWrapper=new LambdaQueryWrapper<>();
        List<Camera> list = cameraMapper.selectList(queryWrapper);
        if(StringUtils.isEmpty(list)){
            return null;
        }
        else {
            return list;
        }
    }

    @Override
    public void insert(Camera camera) {
        cameraMapper.insert(camera);
    }

    @Override
    public Camera getCameraById(Integer id) {
        Camera camera = cameraMapper.selectById(id);
        if(camera==null){
            return null;
        }
        else {
            return camera;
        }
    }

    @Override
    public void updateCamera(Camera camera) {
         cameraMapper.updateById(camera);
    }

    @Override
    public void deleteCamera(Integer id) {
        cameraMapper.deleteById(id);
    }

    @Override
    public Integer getAccessCount() {
        Integer count = cameraMapper.getAccessCount();
        return count;
    }

    @Override
    public Integer getAiCount() {
        Integer count = cameraMapper.getAiCount();
        return count;
    }
}
